#pragma once
#include "../server.hpp"

namespace umtl
{
	//////////////////////////////////////////////////////////////////////////
	//

	class tcp_server : public server< tcp >
	{
	public:
		typedef std::tr1::function< void(connection*) > accept_handler_t;

		tcp_server( unsigned short int port
			, tcp_server::accept_handler_t accept_handler
			, tcp_server::read_handler_t read_handler
			, tcp_server::close_handler_t close_handler );
		
	private:
		void start_accept();

		void handle_accept( tcp_server::connection * new_connection, const boost::system::error_code & error );

		boost::asio::io_service io_service_;
		boost::asio::strand strand_;
		tcp::acceptor acceptor_;

		boost::asio::detail::wrapped_handler< boost::asio::strand, accept_handler_t > accept_handler_;
	};

	//////////////////////////////////////////////////////////////////////////
}